package com.zys;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class text {
    public static void main(String[] args) {
        List<String> ls = new ArrayList<>();
        ls.add("aaa");
        ls.add("bbb");
        ls.add("ccc");
        ls.add("ddd");
        Iterator<String> i = ls.iterator();
        System.out.println(i.next());
        for(String s:ls){
            System.out.print(s+" ");
        }
        System.out.println();
        ls.forEach((String s)->{
            System.out.print(s+" ");
        });
        System.out.println();
        ListIterator<String> li = ls.listIterator();
        while (li.hasNext()){
           String s  = li.next();
            System.out.print(s+" ");
            if(s.equals("bbb")){
                li.add("sss");
            }
        }
        System.out.println();
        System.out.println(ls);


    }
}
